package edu.pku.dao;

import java.sql.SQLException;
import java.util.List;

import com.ibatis.sqlmap.client.SqlMapClient;

import edu.pku.data.DepositoryShell;
import edu.pku.data.Product;
import edu.pku.data.ProductStore;
import edu.pku.util.MySqlMapClient;


public class ProductStoreDao {
	
	public void addProductStore(ProductStore ps) throws SQLException
	{
		SqlMapClient sqlMap = MySqlMapClient.getSqlMapInstance();
		sqlMap.insert("insert_product_store",ps);
	}
	
	public void updateProductStore(ProductStore ps) throws SQLException
	{
		SqlMapClient sqlMap = MySqlMapClient.getSqlMapInstance();
		sqlMap.update("update_product_store",ps);
	}
	
	public void deleteProductStore(ProductStore ps) throws SQLException
	{
		SqlMapClient sqlMap = MySqlMapClient.getSqlMapInstance();
		sqlMap.delete("delete_product_store",ps);
	}
	
	public List<Product> getProductsByShell(DepositoryShell ds) throws SQLException
	{
		SqlMapClient sqlMap = MySqlMapClient.getSqlMapInstance();
		List<Product> list =  sqlMap.queryForList("get_products_by_shell",ds);
		return list;
	}
	
	public List<DepositoryShell> getShellsByProduct(Product p) throws SQLException
	{
		SqlMapClient sqlMap = MySqlMapClient.getSqlMapInstance();
		List<DepositoryShell> list =  sqlMap.queryForList("get_shells_by_product",p);
		return list;
	}
}
